package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author jack
 * @data 2024 9:24
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 素材上传
     *
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    public ResponseResult upload(MultipartFile multipartFile) {
        log.info("接收到素材上传请求,请求参数：{}", multipartFile.getOriginalFilename());
        return wmMaterialService.upload(multipartFile);
    }

    /**
     * 素材列表
     *
     * @param materialDto
     * @return
     */
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmMaterialDto materialDto){
        return wmMaterialService.queryByPage(materialDto);
    }

    @GetMapping("testJVM")
    public ResponseResult testJVM(){
        return ResponseResult.okResult("success");
    }
}
